package pers.cz.postgirl.listener;

import com.alibaba.fastjson.JSON;
import javassist.CannotCompileException;
import pers.cz.postgirl.config.EvenType;
import pers.cz.postgirl.core.EnhanceModel;

import java.lang.reflect.Type;

/**
 * @program: postgirl-client
 * @description:
 * @author: Cheng Zhi
 * @create: 2023-05-23 12:30
 **/
public class Main {

    int a = 9;

    public void test1() {
        a = 10;
        System.out.println(a);
    }

    public void test2() {
        System.out.println("a的值为:" + a++);
    }

    public static void main(String[] args) throws CannotCompileException {

        Main main = new Main();
        System.out.println(main.a);
        main.test1();
        main.test2();
        System.out.println(main.a);

    }

    public void enhance(EvenType evenType, String src) throws CannotCompileException {
        switch (evenType) {
            case AFTER:
                System.out.println("after");
                return;
            case BEFORE:
                System.out.println("before");
                return;
            case THROW:
                System.out.println("throw");
                return;
        }
    }

    private void test() {
        try {
            pers.cz.postgirl.core.Spy spy = new pers.cz.postgirl.core.Spy();
            spy.setStartTime(System.currentTimeMillis());          spy.setMethodName("execute");
            spy.setClzName("org.apache.ibatis.binding.MapperMethod");
            //spy.addParam("java.lang.Object[]",$2);
            spy.setDataType(pers.cz.postgirl.core.Spy.DataType.INPUT);
            if(pers.cz.postgirl.core.SpyHandler.judgePlayback()) {
                pers.cz.postgirl.core.Spy myResult$ = pers.cz.postgirl.core.SpyHandler.getResult(spy);
                com.alibaba.fastjson.JSON.parseObject(com.alibaba.fastjson.JSON.toJSONString(myResult$.getReturnValue()), myResult$.obtainRealRypeClazz());          }
            pers.cz.postgirl.core.SpyHandler.onHandle(spy);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
